package collector.core.util;

import static org.quartz.SimpleScheduleBuilder.simpleSchedule;

import java.util.Calendar;
import java.util.Date;

import org.quartz.JobListener;
import org.quartz.ScheduleBuilder;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleTrigger;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.matchers.KeyMatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import collector.core.CollectConstants;
import collector.task.JobTaskVO;

import system.common.Constants;

/**
 * <pre>
 * Class : collector.schedule.ScheduleUtil / ScheduleUtil.java
 * 	Define Class Object : 
 * <br>
 * </pre>
 * @author ytjeong / apexcns,Inc.
 * @version 1.0
 * @see javadoc
 * @since 2012. 9. 12.
 */
public class ScheduleUtil {

    private static Logger _log = LoggerFactory.getLogger(ScheduleUtil.class);
    private static final String _LogPrefixStr = CollectConstants.LOGGER_MODULE_NAME_SCU + CollectConstants.LOGGER_MODULE_NAME_AFTFIX;

    // First we must get a reference to a scheduler
    public static SchedulerFactory sf = new StdSchedulerFactory();

    //TODO::put collectorConstants
    private static String initJobIds = "Blue-Module";
    @SuppressWarnings("unused")
    private static int jobSubCount = 1;
    @SuppressWarnings("unused")
    private static int jobState = 1; // ON

    /**
     * <pre>
     * Method : ScheduleUtil.getScheduleBuilder()
     * 		주기에 따라 스케줄을 작성해 리턴한다.
     * 		durationValue는 기본 값 1로 정의됨.
     * <br>
     * 	return type of ScheduleBuilder<SimpleTrigger>
     * <br>
     * @param durationType	주기 구분자 { DAY, HOUR, MIN, SEC }
     * @return 
     * </pre>
     */
    public static ScheduleBuilder<SimpleTrigger> getScheduleBuilder(String durationType) {
	return getScheduleBuilder(durationType, 1);
    }
    
    /**
     * <pre>
     * Method : ScheduleUtil.getScheduleBuilder()
     * 		durationValue로 정의된 주기에 따라 스케줄을 작성해 리턴한다.
     * <br>
     * 	return type of ScheduleBuilder<SimpleTrigger>
     * <br>
     * @param durationType	주기 구분자 { DAY, HOUR, MIN, SEC }
     * @param durationValue	주기 값 (정수)
     * @return 
     * </pre>
     */
    public static ScheduleBuilder<SimpleTrigger> getScheduleBuilder(String durationType, int durationValue) {

        ScheduleBuilder<SimpleTrigger> schedBuilder = null;

        if ( CollectConstants.DURATION_SECOND.equals(durationType) ) {	// 매 지정 초마다  
            schedBuilder = simpleSchedule()
                    .withIntervalInSeconds(durationValue)
                    .repeatForever();
        } else if ( CollectConstants.DURATION_MINUTE.equals(durationType) ) {	// 매 지정 분마다 
            schedBuilder = simpleSchedule()
        	    .withIntervalInMinutes(durationValue)
                    .repeatForever();
        } else if ( CollectConstants.DURATION_HOUR.equals(durationType) ) {	// 매 지정 시마다 
            schedBuilder = simpleSchedule()
                    .withIntervalInHours(durationValue)
                    .repeatForever();
        } else if ( CollectConstants.DURATION_DAY.equals(durationType) ) {	// 매 지정 일마다 
            schedBuilder = simpleSchedule()
                    .withIntervalInHours(24*durationValue)
                    .repeatForever();
        }
	
        return schedBuilder;
    }
    
    /** <pre>
     * Method : ScheduleUtil.scheduleJobTask()
     * 		정의된 JobTaskVO를 넘겨받은 sched 스케줄러에 스케줄하고 
     * 		스케줄된 시간을 Vo에 세팅한 후 sched를 리턴한다.
     * <br>
     * 	return type of Scheduler
     * <br>
     * @param sched
     * @param jobTaskVo
     * @return 
     * </pre>
     */
    public static Scheduler scheduleJobTask(Scheduler sched, JobTaskVO jobTaskVo) throws Exception {
	
	if(!StringUtil.isEmpty(jobTaskVo.getJobIDs())) initJobIds = jobTaskVo.getJobIDs(); 
        // initialization parameters into the job
        // jobTaskVo.setJob( JobTaskUtil.initJob(jobTaskVo.getJob(), initJobIds, jobSubCount, jobState) );

	String defineClass = CollectConstants.DEFAULT_LISTENER_PACKAGESTR + "."+initJobIds+CollectConstants.DEFAULT_LISTENER_NAME_AFTFIX;
	String deaultClass = CollectConstants.DEFAULT_LISTENER_PACKAGESTR + "." + CollectConstants.DEFAULT_LISTENER_CLASSSTR;
	
        Class<?> taskClass = null;
        //JobListener taskClass = null;
	try {// 지정된 TaskListener 클래스를 정의
	    // Listener Name is jobTaskName + "_JobListener"
	    taskClass	= Class.forName(defineClass);
	    
	} catch (ClassNotFoundException e) {
	    _log.warn(_LogPrefixStr + " retry Default Definition for Listener Class :: "+e.getMessage() + " to " + deaultClass);
	    try {// TaskListener 클래스가 없는 경우 default TaskListener 클래스를 정의, 
		 // default Listener Name is listenerClassName
		taskClass	= Class.forName(deaultClass);
		
	    } catch (ClassNotFoundException e1) {
		//TaskListener 클래스가 없는 경우 처리 방안 (Scheduler 예외발생)
		_log.warn(_LogPrefixStr + " Fail Default Definition for Listener Class :: "+e1.getMessage(), e1);
		throw e1;
	    }
	}
	
    	// TODO::Remove Listener attached to jobKey
        try {
	    sched.getListenerManager().addJobListener(
	    		//new ModuleJobListener(), 
	    		(JobListener) taskClass.newInstance(), 
	    		KeyMatcher.keyEquals(jobTaskVo.getJobKey())
	    );
	} catch (Exception e) {	// 리스너는 없어도 작업 돌리는 건과는 무관
	    _log.warn(_LogPrefixStr + "Job Task Listener Setting Error - "+ e.getClass().getName() + ": " + e.getMessage(), e);
	}
        
        // schedule the job to run
        Date scheduledTime;
	try {
	    scheduledTime = sched.scheduleJob( jobTaskVo.getJob(),  jobTaskVo.getTrigger());
	    jobTaskVo.setScheduleTime(scheduledTime);	// 스케줄된 시간 세팅
	    _log.info(_LogPrefixStr + "----- Scheduled Job Tasks ["+jobTaskVo.getJobIDs()+", reg="+jobTaskVo.getRegistScheduleTime()+", sch="+jobTaskVo.getScheduleTime()+"] ----------------");
	    _log.debug(_LogPrefixStr + " \t스케줄된 작업 :: "+jobTaskVo.toStringInfoSchedule());
	} catch (SchedulerException e) {
	    _log.error(_LogPrefixStr + "Job Task Schedule Setting Error - "+ e.getClass().getName() + ": " + e.getMessage(), e);
	    throw e;
	}
      
	return sched;
    }

    /**
     * <pre>
     * Method : ScheduleUtil.getScheduleRegistTime()
     * 		시분초(pTime)를 기준으로 등록할 Date 시각을 회득, Ex) HHmmss
     * <br>
     * 	return type of Date
     * <br>
     * @param pTime
     * @return 
     * </pre>
     */
    public static Date getScheduleRegistTime(String pTime) {
	// TODO:: Need //Validate pTime format /HHmmss/
	return DateUtil.parseDate(
		DateUtil.dateAddFormat(Calendar.DATE, 
							0, 
							Constants.simDf_Day.format(DateUtil.now()), 
							"yyyyMMdd") + pTime
		); // Start from Time
    }

    /**
     * <pre>
     * Method : ScheduleUtil.getScheduleCurrentTime()
     * 		시분초(pTime)를 기준으로 현재일시에서 pastValue일을 더하거나 뺀 과거 Date 시각을 회득, Ex) HHmmss, #
     * <br>
     * 	return type of Date
     * <br>
     * @param pTime
     * @param pastValue
     * @return 
     * </pre>
     */
    public static Date getScheduleCurrentTime(String pTime, int pastValue) {
	// TODO:: Need //Validate pTime format /HHmmss/
//	DateUtil.now();
//	DateUtil.getTimelong();
//	DateUtil.getCurrentDate("yyyyMMddHHmmss");
	
	return DateUtil.parseDate(
		DateUtil.dateAddFormat(Calendar.DATE, // 일
							pastValue, 
							DateUtil.now(), 
							//Constants.simDf_Day.format(new Date(Constants.currentTime)), 
							"yyyyMMddHHmmss")
		); // Current from Time
    }
    
    /**
     * <pre>
     * Method : ScheduleUtil.convScheduleCurrentTime()
     * 		주어진 시각(scheduleDateStr//HHmmss, durationType, durationType, pastDayValue)을 기준으로 
     * 		현재 시각에 맞추어 시각을 리턴한다. 
     * 		pastDayValue는 DURATION_DAY 타입인 경우만 활성화 됨.
     * <br>
     * 	return type of String
     * <br>
     * @param scheduleTimeStr
     * @param durationType
     * @param durationValue
     * @param pastDayValue
     * @return 
     * </pre>
     */
    public static String convScheduleCurrentTime(String scheduleTimeStr, String durationType, int durationValue, int pastDayValue) {
	String ScheduleCurrentTime = null;
	Date oDate = ScheduleUtil.getScheduleCurrentTime(scheduleTimeStr, pastDayValue);
	if (CollectConstants.DURATION_DAY.equals(durationType)) {
	    ScheduleCurrentTime = DateUtil.dateToYmd(oDate, "yyyyMMdd"); // HHmmss
	} 
	oDate = ScheduleUtil.getScheduleCurrentTime(scheduleTimeStr, 0); // DAY만 pastDayValue 적용, 나머지는 비적용
	if (CollectConstants.DURATION_HOUR.equals(durationType)) {
	    ScheduleCurrentTime = DateUtil.dateToYmd(oDate, "yyyyMMddHH"); // HHmmss
	    
	} else if (CollectConstants.DURATION_MINUTE.equals(durationType)) {
	    ScheduleCurrentTime = DateUtil.dateToYmd(oDate, "yyyyMMddHHmm"); // HHmmss
	    
	} else if (CollectConstants.DURATION_SECOND.equals(durationType)) {
	    ScheduleCurrentTime = DateUtil.dateToYmd(oDate, "yyyyMMddHHmmss"); // HHmmss
	    
	}
	return ScheduleCurrentTime;
    }

    public static String convScheduleFromTime(String scheduleTimeStr, String durationType, int durationValue, int pastDayValue) {

	String ScheduleFromTime = null;
	
	Date oDate = ScheduleUtil.getScheduleCurrentTime(scheduleTimeStr, pastDayValue);
	//System.out.println("----- 시분초(pTime)를 기준으로 pastValue를 더한 Date 시각을 회득, Ex) HHmmss | getScheduleCurrentTime |" + scheduleTimeStr + ", "+ pastDayValue + " ---> " + oDate + ", " + DateUtil.dateToYmd(oDate, "yyyyMMddHHmmss") );
	if (CollectConstants.DURATION_DAY.equals(durationType)) {
	    ScheduleFromTime = DateUtil.dateToYmd(DateUtil.dateAdd(Calendar.DATE, -1*durationValue, oDate), "yyyyMMdd"); // HHmmss
	} 
	oDate = ScheduleUtil.getScheduleCurrentTime(scheduleTimeStr, 0);
	if (CollectConstants.DURATION_HOUR.equals(durationType)) {
	    ScheduleFromTime = DateUtil.dateToYmd(DateUtil.dateAdd(Calendar.HOUR, -1*durationValue, oDate), "yyyyMMddHH"); // HHmmss
	    
	} else if (CollectConstants.DURATION_MINUTE.equals(durationType)) {
	    ScheduleFromTime = DateUtil.dateToYmd(DateUtil.dateAdd(Calendar.MINUTE, -1*durationValue, oDate), "yyyyMMddHHmm"); // HHmmss
	    
	} else if (CollectConstants.DURATION_SECOND.equals(durationType)) {
	    ScheduleFromTime = DateUtil.dateToYmd(DateUtil.dateAdd(Calendar.SECOND, -1*durationValue, oDate), "yyyyMMddHHmmss"); // HHmmss
	    
	}
	return ScheduleFromTime;
    }

    public static void testScheduleTime(String msg, String pTime) {
	int pastValue = 1;
	int durationValue = 1;
	
	testScheduleTime(msg, pTime, pastValue, durationValue);
    }
    public static void testScheduleTime(String msg, String pTime, int pastValue, int durationValue) {

	String cdateStr = DateUtil.getCurrentDate("yyyyMMddHHmmss");
	String oDateTimeString = null;
	String oDateTimeFrString = null;
	String durationType = null;

	System.out.println("["+msg+"]=============================================================");
	System.out.println("convScheduleFromTime :: 시분초(pTime)를 기준으로 pastValue를 더한 Date 시각을 회득");
	System.out.println("convScheduleCurrentTime :: 주어진 시각을 기준으로 현재 시각에 맞추어 시각을 리턴");
	System.out.println("");
//	System.out.println("\tInfo Param :: 현재시각=" + cdateStr + ", pTime=" + pTime + ", "+ pastValue + " 이전까지" + ", "+ durationValue + " 동안"); 
	
	durationType = CollectConstants.DURATION_DAY;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	dispInfo(cdateStr, pTime, durationType, pastValue, durationValue, oDateTimeFrString, oDateTimeString);
	
	durationType = CollectConstants.DURATION_HOUR;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	dispInfo(cdateStr, pTime, durationType, pastValue, durationValue, oDateTimeFrString, oDateTimeString);
	
	durationType = CollectConstants.DURATION_MINUTE;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	dispInfo(cdateStr, pTime, durationType, pastValue, durationValue, oDateTimeFrString, oDateTimeString);
																																																																																																																																																																																			
	durationType = CollectConstants.DURATION_SECOND;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	dispInfo(cdateStr, pTime, durationType, pastValue, durationValue, oDateTimeFrString, oDateTimeString);
	
	System.out.println("=============================================================");
    }
    
    public static void dispInfo(String cdateStr, String pTime, String durationType, int pastValue, int durationValue, String oDateTimeFrString, String oDateTimeString){
	String preDay = "이후";
	String preUnit = "";
	String preForm = "";
	if ( pastValue < 0 ) { preDay = "이전"; }
	
	String desc = " 현재까지";
	if ( durationType.equals(CollectConstants.DURATION_DAY) ) { preUnit = "일"; preForm = "yyyyMMdd"; desc = " "+ pastValue + " 일 "+preDay+"까지"; }
	if ( durationType.equals(CollectConstants.DURATION_HOUR) ) { preUnit = "시간"; preForm = "yyyyMMddhh"; }
	if ( durationType.equals(CollectConstants.DURATION_MINUTE) ) { preUnit = "분"; preForm = "yyyyMMddHHmm"; }
	if ( durationType.equals(CollectConstants.DURATION_SECOND) ) { preUnit = "초"; preForm = "yyyyMMddHHmmss"; }
	
	//dispInfo(cdateStr, pTime, durationType, pastValue, durationValue, oDateTimeFrString, oDateTimeString);
	System.out.print("\tInfo Param :: 등록시각 pTime=" + pTime + ", "+ desc + ", "+ durationValue + " " + preUnit + " 동안 " + preForm + " "); 
	System.out.println(" ---> Fr[" + oDateTimeFrString + "]~Cr[" + oDateTimeString+"]" + " 현재시각=" + cdateStr + ""); 
    }


    public static void doTestMain() {
	//System.out.println(getFmtDuration(1199800, "H시 m분 s초"));

	String pTime = "211234"; // HHmmss
	Date oDate = null;
	    
	oDate = getScheduleRegistTime(pTime);
	System.out.println("시분초를 기준으로 Date 시각을 회득, Ex) HHmmss | getScheduleStartTime |" + pTime + " ---> " + oDate); 

	int pastValue = 1;
	pastValue = 2;
	oDate = getScheduleCurrentTime(pTime, pastValue);
	System.out.println("시분초(pTime)를 기준으로 pastValue를 더한 Date 시각을 회득, Ex) HHmmss | getScheduleCurrentTime |" + pTime + ", "+ pastValue + " ---> " + oDate); 

	pastValue = -2;
	oDate = getScheduleCurrentTime(pTime, pastValue);
	System.out.println("시분초(pTime)를 기준으로 pastValue를 더한 Date 시각을 회득, Ex) HHmmss | getScheduleCurrentTime |" + pTime + ", "+ pastValue + " ---> " + oDate); 

	String oDateTimeString = null;
	String oDateTimeFrString = null;
	String durationType = null;
	int durationValue = 1;

	durationType = CollectConstants.DURATION_DAY;
	durationValue = 1;
	pastValue = 0;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	System.out.println("주어진 시각을 기준으로 현재 시각에 맞추어 시각을 리턴, Ex) HHmmss | convScheduleCurrentTime |" + pTime + ", "+ durationType + ", "+ durationValue + ", past="+ pastValue + " ---> " + oDateTimeFrString + "~" + oDateTimeString); 
	
	durationType = CollectConstants.DURATION_DAY;
	durationValue = 1;
	pastValue = -2;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	System.out.println("주어진 시각을 기준으로 현재 시각에 맞추어 시각을 리턴, Ex) HHmmss | convScheduleCurrentTime |" + pTime + ", "+ durationType + ", "+ durationValue + ", past="+ pastValue + " ---> " + oDateTimeFrString + "~" + oDateTimeString); 
	
	durationType = CollectConstants.DURATION_DAY;
	durationValue = 2;
	pastValue = -1;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	System.out.println("주어진 시각을 기준으로 현재 시각에 맞추어 시각을 리턴, Ex) HHmmss | convScheduleCurrentTime |" + pTime + ", "+ durationType + ", "+ durationValue + ", past="+ pastValue + " ---> " + oDateTimeFrString + "~" + oDateTimeString); 
	
	durationType = CollectConstants.DURATION_HOUR;
	durationValue = 1;
	pastValue = -2;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	System.out.println("주어진 시각을 기준으로 현재 시각에 맞추어 시각을 리턴, Ex) HHmmss | convScheduleCurrentTime |" + pTime + ", "+ durationType + ", "+ durationValue + ", past="+ pastValue + " ---> " + oDateTimeFrString + "~" + oDateTimeString); 
	
	durationType = CollectConstants.DURATION_MINUTE;
	durationValue = 1;
	pastValue = -2;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	System.out.println("주어진 시각을 기준으로 현재 시각에 맞추어 시각을 리턴, Ex) HHmmss | convScheduleCurrentTime |" + pTime + ", "+ durationType + ", "+ durationValue + ", past="+ pastValue + " ---> " + oDateTimeFrString + "~" + oDateTimeString); 

	durationType = CollectConstants.DURATION_SECOND;
	durationValue = 10;
	pastValue = -2;
	oDateTimeFrString = convScheduleFromTime(pTime, durationType, durationValue, pastValue);
	oDateTimeString = convScheduleCurrentTime(pTime, durationType, durationValue, pastValue);
	System.out.println("주어진 시각을 기준으로 현재 시각에 맞추어 시각을 리턴, Ex) HHmmss | convScheduleCurrentTime |" + pTime + ", "+ durationType + ", "+ durationValue + ", past="+ pastValue + " ---> " + oDateTimeFrString + "~" + oDateTimeString); 

	System.out.println("기타 DateUtil Test ------------------------------------");
	DateUtil.main(null);

//	Date d = DateUtil.now();
//	System.out.println("현재시각 | "+d);
//	System.out.println("3일 증가 | "+DateUtil.dateAdd(Calendar.DATE, 3, d));
//	System.out.println("3일 증가 | "+DateUtil.dateAddFormat(Calendar.DATE, 3, d));
//	System.out.println("3일 증가 | "+DateUtil.dateAddFormat(Calendar.DATE, 3, d, "yyyy-MM-dd"));
//	System.out.println("1일 감소 | "+DateUtil.dateAddFormat(Calendar.DATE, -1*1, d, "yyyyMMddHHmmss"));
//	System.out.println("1일 감소 | "+DateUtil.dateAddFormat(Calendar.DATE, -1*1, Constants.simDf_Day.format(new Date(Constants.currentTime)), "yyyyMMddHHmmss"));
//	System.out.println("기준시각 | "+new Date(Constants.currentTime)+", 일자 | "+Constants.simDf_Day.format(new Date(Constants.currentTime)));
//	System.out.println("일시분초 | "+Constants.simDf.format(new Date(Constants.currentTime)));
//	System.out.println("일자 | "+Constants.simDf_Day.format(new Date(Constants.currentTime)));
//	System.out.println("일시 | "+Constants.simDf_Hour.format(new Date(Constants.currentTime)));
//	System.out.println("일시분 | "+Constants.simDf_Min.format(new Date(Constants.currentTime)));
	    
	System.out.println("기타 Test ------------------------------------");
	Date dat = DateUtil.parseDate(
					DateUtil.dateAddFormat(Calendar.DATE, -1*1, new Date(System.currentTimeMillis()), "yyyyMMddHHmmss") );
	System.out.println("기준 Date 1일 감소 | " + dat); 
	String  ScheduleStartTime = DateUtil.dateToYmd(dat, "yyyyMMddHHmmss");
	System.out.println("	일자 yyyyMMddHHmmss | dateToYmd | " + ScheduleStartTime); 
			
	dat = getScheduleCurrentTime("020023", 1);
	System.out.println("기준 Date 1일 증가 | " + dat); 
	ScheduleStartTime = DateUtil.dateToYmd(dat, "yyyyMMddHHmmss");
	System.out.println("	일자 yyyyMMddHHmmss | dateToYmd | " + ScheduleStartTime); 
	    
//	System.out.println("" + convScheduleCurrentTime("020023", "DAY", 1, 1));
//	System.out.println("" + convScheduleCurrentTime("020023", "DAY", 1, 1));
//	System.out.println("" + convScheduleCurrentTime("020023", "HOUR", 1, 1));
//	System.out.println("" + convScheduleCurrentTime("020023", "MIN", 1, 1));
//	System.out.println("" + convScheduleCurrentTime("020023", "SEC", 10, 1));

    }
    
    /**
     * <pre>
     * Method : ScheduleUtil.main()
     * 		ScheduleUtil Method 들에 대한 test
     * <br>
     * 	return type of void
     * <br>
     * @param args 
     * </pre>
     */
    public static void main(String[] args) {
	//System.out.println(getFmtDuration(1199800, "H시 m분 s초"));

	//doTestMain();
	
	String pTime = "130000";
	pTime = "100000";
	testScheduleTime("[과거] 현재부터 이전 3", pTime, 0, 3);
	testScheduleTime("[과거] 현재부터 이전 3", pTime, -2, 3);
	testScheduleTime("[과거] 현재부터 이전 3", pTime, 1, 3);
	pTime = "210000";
	testScheduleTime("[미래] 현재부터 이전 3", pTime, 0, 3);
	testScheduleTime("[미래] 현재부터 이전 3", pTime, -2, 3);
    }

    // FIXME::List JobListener Regist
//    /** <pre>
//     * Method : ScheduleUtil.addJobListenerForJobTasks()
//     * 
//     * <br>
//     * 	return type of Scheduler
//     * <br>
//     * @param sched
//     * @param arrayList
//     * @return 
//     * </pre>
//     */
//    public static Scheduler addJobListenerForJobTasks(Scheduler sched,
//	    List<Matcher<Jobkey>> matcherJobList) {
//
//        sched.getListenerManager().addJobListener(new ModuleJobListener(), matcherJobList);
//        List<Matcher<Jobkey>> matcherJobList = new ArrayList();
//        KeyMatcher.keyEquals(jobTaskVo.getJobKey());
//        
//        KeyMatcher.keyEquals(jobTaskVo.getJobKey());
//
//	return sched;
//    }
}
